﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using EkejiWeb.Model;
using EkejiWeb.BLL;
using System.Data;

namespace EkejiWeb.Web.Admin.AdminUser
{
    public partial class Select : System.Web.UI.Page
    {
        AdminModel model = new AdminModel();
        AdminBLL bll = new AdminBLL();
        DataSet ds;
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                ds = bll.GetAllList();
                BindData();
            }
        }
        private void BindData()
        {
            PagedDataSource ps = new PagedDataSource();
            ps.DataSource = ds.Tables[0].DefaultView;
            ps.AllowPaging = true;
            AspNetPager1.RecordCount = ds.Tables[0].Rows.Count;
            ps.CurrentPageIndex = AspNetPager1.CurrentPageIndex - 1;
            ps.PageSize = AspNetPager1.PageSize;
            rptUser.DataSource = ps;
            rptUser.DataBind();
        }
        protected void AspNetPager1_PageChanged(object src, EventArgs e)
        {
            string str = "id>1";
            ds = bll.GetList(str);
            BindData();
        }
        protected void btnSelect_Click(object sender, EventArgs e)
        {
            string username = tbUserName.Text.Trim();
            ds = bll.SelectAdminByUserName(username);
            if (ds.Tables[0].Rows.Count > 0)
            {
                BindData();
            }
            else
            {
                Response.Write("<Script Language=JavaScript>alert('查询的用户不存在！');</Script>");
                return;
            }
        }
    }
}